package com.neusoft.neuiotms.dcam.fixed.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "neuiot_fixed_maintenance_reminder")
@org.hibernate.annotations.Table(appliesTo = "neuiot_fixed_maintenance_reminder", comment = "固定资产维保到期提醒设置表")
public class MaintenanceReminder extends AbstractModel {

    private static final long serialVersionUID = 1L;

    @Length(max = 255, message = "维保到期提醒名称不能超过{max}位")
    @Column(length = 255, nullable = false, unique = true)
    @Comment("varchar(255) NOT NULL COMMENT '名称'")
    private String name;

    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '提醒周期'")
    private Integer reminderDay;

    /** 提醒用户 */
    @ManyToMany(targetEntity = ConnectionRelation.class, cascade = CascadeType.ALL)
    @JoinTable(name = "ref_maintenance_reminder_user", joinColumns = {
            @JoinColumn(name = "reminder_id", referencedColumnName = "id") }, inverseJoinColumns = {
                    @JoinColumn(name = "connect_id", referencedColumnName = "id") })
    @LazyCollection(LazyCollectionOption.TRUE)
    List<ConnectionRelation> users;

    /** 提醒类型 */
    @ManyToMany(targetEntity = AssetType.class)
    @JoinTable(name = "ref_maintenance_reminder_type", joinColumns = {
            @JoinColumn(name = "reminder_id", referencedColumnName = "id") }, inverseJoinColumns = {
                    @JoinColumn(name = "type_id", referencedColumnName = "id") })
    @LazyCollection(LazyCollectionOption.TRUE)
    List<AssetType> assetTypes;

    @Length(max = 32, message = "通知类型不能超过{max}位")
    @Column(length = 32, nullable = true)
    @Comment("varchar(32) NULL DEFAULT NULL COMMENT '通知类型'")
    private String noticeType;

    @Length(max = 1023, message = "备注不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(1023) NULL DEFAULT NULL COMMENT '备注'")
    private String note;

}
